home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Devices / Apple Desktop Bus / ADB Key Spy / Sources / ADB Key Spy Main.c next >
Encoding:
Text File  |  1995-09-20  |  1009 b   |  49 lines  |  [TEXT/MMCC]

  1.     //
  2.     //    ADB Key Spy Main • Pete Gontier • gurgle@apple.com
  3.     //    Macintosh Developer Technical Support
  4.     //    © 1995 Apple Computer, Inc.
  5.     //
  6.     //    See "ADB Key Spy.h" for more information.
  7.     //
  8.  
  9. #ifndef __DIALOGS__
  10. #    include <Dialogs.h>
  11. #endif
  12.  
  13. #ifndef __FONTS__
  14. #    include <Fonts.h>
  15. #endif
  16.  
  17. #include "ADB Key Spy.h"
  18.  
  19. void main (void)
  20. {
  21.     Boolean            scratch;
  22.     EventRecord        event;
  23.  
  24.     InitGraf (&(qd.thePort));
  25.     InitFonts ( );
  26.     InitWindows ( );
  27.     InitMenus ( );
  28.     TEInit ( );
  29.     InitDialogs (nil);
  30.  
  31.     AKS_AcquireKeyboards ( );
  32.  
  33.     //
  34.     //    This is a more interesting sequence than one might guess.
  35.     //    Since this package now performs raw-to-virtual key code translation,
  36.     //    it's non-trivial to pass the key code from an event record to
  37.     //    AKS_IsKeyDownAnywhere.
  38.     //
  39.  
  40.     while (!WaitNextEvent (keyDownMask,&event,0xFFFFFFFF,nil))
  41.         ;
  42.     scratch = AKS_IsKeyDownAnywhere ((event.message & keyCodeMask) >> 8);
  43.  
  44.     AKS_RelinquishKeyboards ( );
  45.  
  46.     if (!scratch)
  47.         DebugStr ("\pWhoa! A keyDown event was posted for a key that isn't down!");
  48. }
  49.